﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace GGGK.Film.Models.Models;

public partial class GGGKFilmContext : DbContext
{
    public GGGKFilmContext()
    {
    }

    public GGGKFilmContext(DbContextOptions<GGGKFilmContext> options)
        : base(options)
    {
    }

    public virtual DbSet<Base_DictInfo> Base_DictInfos { get; set; }

    public virtual DbSet<Base_DictType> Base_DictTypes { get; set; }

    public virtual DbSet<Base_LoginInfo> Base_LoginInfos { get; set; }

    public virtual DbSet<Base_MenuInfo> Base_MenuInfos { get; set; }

    public virtual DbSet<Base_RoleInfo> Base_RoleInfos { get; set; }

    public virtual DbSet<Base_RoleMenu> Base_RoleMenus { get; set; }

    public virtual DbSet<Base_UserAddress> Base_UserAddresses { get; set; }

    public virtual DbSet<Base_UserInfo> Base_UserInfos { get; set; }

    public virtual DbSet<Base_UserRole> Base_UserRoles { get; set; }

    public virtual DbSet<FilmDetail> FilmDetails { get; set; }

    public virtual DbSet<FilmInfo> FilmInfos { get; set; }

    public virtual DbSet<LeaseDetail> LeaseDetails { get; set; }

    public virtual DbSet<LeaseInfo> LeaseInfos { get; set; }

    public virtual DbSet<MovieInfo> MovieInfos { get; set; }

    public virtual DbSet<RoomInfo> RoomInfos { get; set; }

    public virtual DbSet<ShelvesInfo> ShelvesInfos { get; set; }

    public virtual DbSet<TrayInfo> TrayInfos { get; set; }

    public virtual DbSet<VW_Dict> VW_Dicts { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder.UseSqlServer("Name=ConnectionStrings:DefaultConn");

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Base_DictInfo>(entity =>
        {
            entity.ToTable("Base_DictInfo");

            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.DictDesc)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasDefaultValue("-")
                .HasComment("数据描述");
            entity.Property(e => e.DictName)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("数据项");
            entity.Property(e => e.DictOrder)
                .HasDefaultValue(1)
                .HasComment("数据顺序");
            entity.Property(e => e.DictTypeId).HasComment("数据分组类型");
            entity.Property(e => e.DictValue)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("数据值");
            entity.Property(e => e.Status)
                .HasDefaultValue(1)
                .HasComment("数据项状态，1正常，0无效，-1删除");
        });

        modelBuilder.Entity<Base_DictType>(entity =>
        {
            entity.ToTable("Base_DictType");

            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.DictTypeName)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("字典分类");
            entity.Property(e => e.Status)
                .HasDefaultValue(1)
                .HasComment("状态");
        });

        modelBuilder.Entity<Base_LoginInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_LoginInfo");

            entity.ToTable("Base_LoginInfo");

            entity.Property(e => e.CreateTime).HasColumnType("datetime");
            entity.Property(e => e.LoginLastTime).HasColumnType("datetime");
            entity.Property(e => e.LoginName)
                .HasMaxLength(50)
                .IsUnicode(false);
            entity.Property(e => e.LoginPwd)
                .HasMaxLength(50)
                .IsUnicode(false);
            entity.Property(e => e.OpenId)
                .HasMaxLength(100)
                .HasComment("微信的OpenId");
            entity.Property(e => e.ProfilePhoto)
                .HasMaxLength(100)
                .HasComment("头像");

            entity.HasOne(d => d.User).WithMany(p => p.Base_LoginInfos)
                .HasForeignKey(d => d.UserId)
                .HasConstraintName("FK_LoginInfo_UserInfo_UserId");
        });

        modelBuilder.Entity<Base_MenuInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_MenuInfo");

            entity.ToTable("Base_MenuInfo");

            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasColumnType("datetime");
            entity.Property(e => e.MenuIcon).HasMaxLength(50);
            entity.Property(e => e.MenuName).HasMaxLength(50);
            entity.Property(e => e.MenuUrl).HasMaxLength(50);
            entity.Property(e => e.Status).HasDefaultValue(1);
        });

        modelBuilder.Entity<Base_RoleInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_RoleInfo");

            entity.ToTable("Base_RoleInfo");

            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasColumnType("datetime");
            entity.Property(e => e.Remark).HasMaxLength(20);
            entity.Property(e => e.RoleName).HasMaxLength(20);
            entity.Property(e => e.Status).HasDefaultValue(1);
        });

        modelBuilder.Entity<Base_RoleMenu>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_RoleMenu");

            entity.ToTable("Base_RoleMenu");

            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasColumnType("datetime");
            entity.Property(e => e.Status).HasDefaultValue(1);

            entity.HasOne(d => d.Role).WithMany(p => p.Base_RoleMenus)
                .HasForeignKey(d => d.RoleId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FK_RoleMenu_RoleInfo");
        });

        modelBuilder.Entity<Base_UserAddress>(entity =>
        {
            entity.ToTable("Base_UserAddress");

            entity.Property(e => e.CreateTime).HasColumnType("datetime");
            entity.Property(e => e.IsDefault)
                .HasDefaultValue(0)
                .HasComment("是否默认地址");
            entity.Property(e => e.ReceiverAddress)
                .HasMaxLength(100)
                .IsUnicode(false)
                .HasComment("地址");
            entity.Property(e => e.ReceiverCity)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("城市");
            entity.Property(e => e.ReceiverDistrict)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("区县");
            entity.Property(e => e.ReceiverName)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("收货人");
            entity.Property(e => e.ReceiverPhone)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("收货电话");
            entity.Property(e => e.ReceiverState)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("省份");
            entity.Property(e => e.ReceiverZIP)
                .HasMaxLength(20)
                .IsUnicode(false)
                .HasComment("邮编");
        });

        modelBuilder.Entity<Base_UserInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_UserInfo");

            entity.ToTable("Base_UserInfo");

            entity.Property(e => e.CreateTime).HasColumnType("datetime");
            entity.Property(e => e.DeptId).HasDefaultValue(1);
            entity.Property(e => e.Email).HasMaxLength(50);
            entity.Property(e => e.IdCard).HasMaxLength(18);
            entity.Property(e => e.Sex).HasMaxLength(20);
            entity.Property(e => e.Tel).HasMaxLength(30);
            entity.Property(e => e.UserName)
                .HasMaxLength(50)
                .HasComment("用户名称");
        });

        modelBuilder.Entity<Base_UserRole>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_UserRole");

            entity.ToTable("Base_UserRole");

            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasColumnType("datetime");
            entity.Property(e => e.Status).HasDefaultValue(1);
        });

        modelBuilder.Entity<FilmDetail>(entity =>
        {
            entity.ToTable("FilmDetail");

            entity.Property(e => e.CreateTime).HasColumnType("datetime");
            entity.Property(e => e.FilmCode)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("胶片编号");
            entity.Property(e => e.FilmStatus).HasComment("胶片状态");
            entity.Property(e => e.IsRevolution).HasComment("是否转数");
            entity.Property(e => e.RepairStatus).HasComment("修复状态");
            entity.Property(e => e.Sequence).HasComment("顺序");
            entity.Property(e => e.StockStatus).HasComment("库存状态");
            entity.Property(e => e.TrayId).HasComment("托盘位置");

            entity.HasOne(d => d.Film).WithMany(p => p.FilmDetails)
                .HasForeignKey(d => d.FilmId)
                .HasConstraintName("FK_FilmDetail_FilmInfo");
        });

        modelBuilder.Entity<FilmInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_FilmInfo_1");

            entity.ToTable("FilmInfo");

            entity.Property(e => e.CreateTime).HasColumnType("datetime");
            entity.Property(e => e.FilmModelId).HasComment("型号");
            entity.Property(e => e.FilmTypeId).HasComment("片种");
            entity.Property(e => e.MovieId).HasComment("影片编号");
            entity.Property(e => e.Quantity).HasComment("数量");
            entity.Property(e => e.SetsNumber).HasComment("套数");
        });

        modelBuilder.Entity<LeaseDetail>(entity =>
        {
            entity.ToTable("LeaseDetail");

            entity.Property(e => e.FilmCode)
                .HasMaxLength(50)
                .IsUnicode(false);
            entity.Property(e => e.FilmModelId).HasComment("型号");
            entity.Property(e => e.FilmTypeId).HasComment("片种");
            entity.Property(e => e.MovieTile)
                .HasMaxLength(100)
                .IsUnicode(false);
            entity.Property(e => e.Quantity).HasComment("数量");
            entity.Property(e => e.SetsNumber).HasComment("套数");
        });

        modelBuilder.Entity<LeaseInfo>(entity =>
        {
            entity.ToTable("LeaseInfo");

            entity.Property(e => e.Applicant).HasComment("申请人");
            entity.Property(e => e.ApplicationTime)
                .HasComment("申请时间")
                .HasColumnType("datetime");
            entity.Property(e => e.ApprovalRemarks)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasComment("审批意见");
            entity.Property(e => e.ApprovalTime)
                .HasComment("审批时间")
                .HasColumnType("datetime");
            entity.Property(e => e.Approver).HasComment("审批人");
            entity.Property(e => e.BeginTime).HasComment("开始时间");
            entity.Property(e => e.CreateTime).HasColumnType("datetime");
            entity.Property(e => e.EndTime).HasComment("归还时间");
            entity.Property(e => e.FilmNumber).HasComment("胶片数量");
            entity.Property(e => e.LeaseCode)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("租借编码");
            entity.Property(e => e.LeaseDesc)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasComment("租借说明");
            entity.Property(e => e.MovieNumber).HasComment("电影数量");
            entity.Property(e => e.Status).HasComment("状态");
        });

        modelBuilder.Entity<MovieInfo>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_FilmInfo");

            entity.ToTable("MovieInfo");

            entity.Property(e => e.Awards)
                .HasMaxLength(500)
                .IsUnicode(false)
                .HasComment("所获奖励");
            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasColumnType("datetime");
            entity.Property(e => e.MovieCode)
                .HasMaxLength(50)
                .IsUnicode(false);
            entity.Property(e => e.MovieColor)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("颜色");
            entity.Property(e => e.MovieDesc)
                .HasMaxLength(500)
                .IsUnicode(false)
                .HasComment("备注");
            entity.Property(e => e.MovieLength).HasComment("电影时长");
            entity.Property(e => e.MovieTitle)
                .HasMaxLength(100)
                .IsUnicode(false)
                .HasComment("标题");
            entity.Property(e => e.MovieTitle2)
                .HasMaxLength(100)
                .IsUnicode(false)
                .HasComment("标题2");
            entity.Property(e => e.MovieTypeId).HasComment("分类");
            entity.Property(e => e.MovieYears).HasComment("年份");
            entity.Property(e => e.Performer)
                .HasMaxLength(100)
                .IsUnicode(false)
                .HasComment("演职人员");
            entity.Property(e => e.Status).HasDefaultValue(1);
        });

        modelBuilder.Entity<RoomInfo>(entity =>
        {
            entity.ToTable("RoomInfo");

            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasColumnType("datetime");
            entity.Property(e => e.RoomCode)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("房间编号");
            entity.Property(e => e.RoomDesc)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasComment("房间说明");
            entity.Property(e => e.RoomName)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("房间名称");
            entity.Property(e => e.Status).HasDefaultValue(1);
        });

        modelBuilder.Entity<ShelvesInfo>(entity =>
        {
            entity.ToTable("ShelvesInfo");

            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasColumnType("datetime");
            entity.Property(e => e.RoomCode)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("房间编号");
            entity.Property(e => e.ShelvesCode)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("房间编号");
            entity.Property(e => e.ShelvesDesc)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasComment("房间说明");
            entity.Property(e => e.ShelvesName)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("房间名称");
            entity.Property(e => e.Status).HasDefaultValue(1);
        });

        modelBuilder.Entity<TrayInfo>(entity =>
        {
            entity.ToTable("TrayInfo");

            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasColumnType("datetime");
            entity.Property(e => e.RackNumber)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("排架号");
            entity.Property(e => e.RoomCode)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("房间编号");
            entity.Property(e => e.ShelvesCode)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("货架号");
            entity.Property(e => e.Status).HasDefaultValue(1);
            entity.Property(e => e.TrayCode)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("托盘编号");
            entity.Property(e => e.TrayName)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasComment("托盘名称");
        });

        modelBuilder.Entity<VW_Dict>(entity =>
        {
            entity
                .HasNoKey()
                .ToView("VW_Dict");

            entity.Property(e => e.DictName)
                .HasMaxLength(50)
                .IsUnicode(false);
            entity.Property(e => e.DictTypeName)
                .HasMaxLength(50)
                .IsUnicode(false);
            entity.Property(e => e.DictValue)
                .HasMaxLength(50)
                .IsUnicode(false);
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
